Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

chore(build): fix version placeholder matching #15016

Closed

Conversation

gkalpak
Copy link
Member

@gkalpak gkalpak commented Aug 11, 2016

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Bug fix.

What is the current behavior? (You can also link to an open issue here)

angular.version === {
  ...
  major: 'NG_VERSION_MAJOR',
  minor: 'NG_VERSION_MINOR',
  dot: 'NG_VERSION_DOT',
  ...
}

What is the new behavior (if this is a feature change)?

angular.version === {
  ...
  major: 1,
  minor: 5,
  dot: 9,
  ...
}

Does this PR introduce a breaking change?
No.

Please check if the PR fulfills these requirements

Other information:
During the build task, the version placeholders will be replaced with the actual values using a
RegExp, which expects the placeholders to be surrounded by double quotes. By replacing the quotes
from double to single in #15011, the RegExp was not able to match the placeholders.

Btw, this has broken ngMaterial (since they polyfill $animateCss based on the value of angular.version.minor).

@gkalpak
Copy link
Member Author

gkalpak commented Aug 12, 2016

For reference, here are the RegExps that match and replace the version placeholders: lib/grunt/utils.js#L125-L130

expect(version.then(validate)).toBe(true);

function validate(ver) {
return ver.full.indexOf([ver.major, ver.minor, ver.dot].join('.')) === 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just ver.full === [ver.major, ver.minor, ver.dot].join('.')?

Copy link
Member Author

@gkalpak gkalpak Aug 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is not always true. E.g. full can be 1.5.0-rc.2 or 1.5.9-build.4949 or 1.5.9-local+sha.859348c (this last one is what we actually have in the tests most of the time).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Can you add a comment with that info?

During the `build` task, the version placeholders will be replaced with the actual values using a
RegExp, which expects the placeholders to be surrounded by double quotes. By replacing the quotes
from double to single in angular#15011, the RegExp was not able to match the placeholders.

(For reference, the RegExps that match and replace the version placeholders are in
[lib/grunt/utils.js][1].)

[1]: https://github.com/angular/angular.js/blob/859348c7f61ff5f93b9f81eb7f46842bd018d8e3/lib/grunt/utils.js#L125-L130
@gkalpak gkalpak force-pushed the chore-build-fix-version-placeholders branch from 30ba653 to 337b9a9 Compare August 12, 2016 08:21
@gkalpak gkalpak force-pushed the chore-build-fix-version-placeholders branch from df32fc6 to 07e6958 Compare August 12, 2016 09:25
@mgol
Copy link
Member

mgol commented Aug 12, 2016

How about we don't change what you changed here and keep our style but update the regexes so that they accept both string delimiter types? E.g. we'd change:

.replace(/"NG_VERSION_FULL"/g, NG_VERSION.full)

to:

.replace(/(?:'|")NG_VERSION_FULL(?:'|")/g, NG_VERSION.full)

etc.?

EDIT: or:

.replace(/(\\?(?:'|"))NG_VERSION_FULL\1/g, NG_VERSION.full)

.replace(/(['"])NG_VERSION_MAJOR\1/, NG_VERSION.major)
.replace(/(['"])NG_VERSION_MINOR\1/, NG_VERSION.minor)
.replace(/(['"])NG_VERSION_DOT\1/, NG_VERSION.patch)
.replace(/(['"])NG_VERSION_CDN\1/, NG_VERSION.cdn)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could find this anywhere inside the codebase. It is probably not needed, but left it just in case.

@gkalpak
Copy link
Member Author

gkalpak commented Aug 12, 2016

I changed the RegExps to accept both types of quotes. @mgol, PTAL.
(I didn't account for escaped quotes, since we don't need them anywhere if we can use ' and " interchangeably.)

@mgol
Copy link
Member

mgol commented Aug 12, 2016

LGTM

@gkalpak gkalpak closed this in 6304cde Aug 12, 2016
gkalpak added a commit that referenced this pull request Aug 12, 2016
During the `build` task, the version placeholders will be replaced with the actual values using a
RegExp, which expects the placeholders to be surrounded by double quotes. By replacing the quotes
from double to single in #15011, the RegExp was not able to match the placeholders.

(For reference, the RegExps that match and replace the version placeholders are in
[lib/grunt/utils.js][1].)

[1]: https://github.com/angular/angular.js/blob/859348c7f61ff5f93b9f81eb7f46842bd018d8e3/lib/grunt/utils.js#L125-L130

Closes #15016
@gkalpak gkalpak deleted the chore-build-fix-version-placeholders branch August 12, 2016 15:39
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
During the `build` task, the version placeholders will be replaced with the actual values using a
RegExp, which expects the placeholders to be surrounded by double quotes. By replacing the quotes
from double to single in angular#15011, the RegExp was not able to match the placeholders.

(For reference, the RegExps that match and replace the version placeholders are in
[lib/grunt/utils.js][1].)

[1]: https://github.com/angular/angular.js/blob/859348c7f61ff5f93b9f81eb7f46842bd018d8e3/lib/grunt/utils.js#L125-L130

Closes angular#15016
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
During the `build` task, the version placeholders will be replaced with the actual values using a
RegExp, which expects the placeholders to be surrounded by double quotes. By replacing the quotes
from double to single in angular#15011, the RegExp was not able to match the placeholders.

(For reference, the RegExps that match and replace the version placeholders are in
[lib/grunt/utils.js][1].)

[1]: https://github.com/angular/angular.js/blob/859348c7f61ff5f93b9f81eb7f46842bd018d8e3/lib/grunt/utils.js#L125-L130

Closes angular#15016
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
During the `build` task, the version placeholders will be replaced with the actual values using a
RegExp, which expects the placeholders to be surrounded by double quotes. By replacing the quotes
from double to single in angular#15011, the RegExp was not able to match the placeholders.

(For reference, the RegExps that match and replace the version placeholders are in
[lib/grunt/utils.js][1].)

[1]: https://github.com/angular/angular.js/blob/859348c7f61ff5f93b9f81eb7f46842bd018d8e3/lib/grunt/utils.js#L125-L130

Closes angular#15016
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
During the `build` task, the version placeholders will be replaced with the actual values using a
RegExp, which expects the placeholders to be surrounded by double quotes. By replacing the quotes
from double to single in angular#15011, the RegExp was not able to match the placeholders.

(For reference, the RegExps that match and replace the version placeholders are in
[lib/grunt/utils.js][1].)

[1]: https://github.com/angular/angular.js/blob/859348c7f61ff5f93b9f81eb7f46842bd018d8e3/lib/grunt/utils.js#L125-L130

Closes angular#15016
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
During the `build` task, the version placeholders will be replaced with the actual values using a
RegExp, which expects the placeholders to be surrounded by double quotes. By replacing the quotes
from double to single in angular#15011, the RegExp was not able to match the placeholders.

(For reference, the RegExps that match and replace the version placeholders are in
[lib/grunt/utils.js][1].)

[1]: https://github.com/angular/angular.js/blob/859348c7f61ff5f93b9f81eb7f46842bd018d8e3/lib/grunt/utils.js#L125-L130

Closes angular#15016
petebacondarwin pushed a commit that referenced this pull request Nov 24, 2016
During the `build` task, the version placeholders will be replaced with the actual values using a
RegExp, which expects the placeholders to be surrounded by double quotes. By replacing the quotes
from double to single in #15011, the RegExp was not able to match the placeholders.

(For reference, the RegExps that match and replace the version placeholders are in
[lib/grunt/utils.js][1].)

[1]: https://github.com/angular/angular.js/blob/859348c7f61ff5f93b9f81eb7f46842bd018d8e3/lib/grunt/utils.js#L125-L130

Closes #15016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants